package cn.yuan.order.controller;

import cn.yuan.basic.util.LoginContext;
import cn.yuan.basic.util.PageList;
import cn.yuan.order.domain.PetAcquisitionOrder;
import cn.yuan.order.query.PetAcquisitionOrderQuery;
import cn.yuan.order.service.IPetAcquisitionOrderService;
import cn.yuan.pet.domain.Pet;
import cn.yuan.pet.query.PetQuery;
import cn.yuan.user.domain.Logininfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/petAcquisitionOrder")
public class PetAcquisitionOrderController {
    @Autowired
    private IPetAcquisitionOrderService petAcquisitionOrderService;
    @PostMapping("/user")
    public PageList<PetAcquisitionOrder> queryUserOrder(@RequestBody PetAcquisitionOrderQuery query, HttpServletRequest request){
        Logininfo logininfo = LoginContext.getLoginInfo(request);
        return petAcquisitionOrderService.queryUserOrder(query,logininfo.getId());
    }

    @PostMapping()
    public PageList<PetAcquisitionOrder> queryOrder(@RequestBody PetAcquisitionOrderQuery query,HttpServletRequest request){
        Logininfo loginInfo = LoginContext.getLoginInfo(request);
        return petAcquisitionOrderService.queryOrder(query,loginInfo.getId());
    }
}
